<template>
    <section v-loading="loading" class="cms-body">
        <div class="cms-list-header flex-between">
            <!-- 右操作 -->
	        <div>
		        <el-select v-model="params.resourceTypeId" @change="queryByJson">
			        <el-option label="所有资源类型" value="0"></el-option>
			        <el-option v-for="(item,index) in resourceTypeGroup" :key="index" :label="item.typeName"
			                   :value="item.id"></el-option>
		        </el-select>
		        <el-select v-model="params.resourceSubjectId" @change="queryByJson">
			        <el-option label="所有资源学科" value="0"></el-option>
			        <el-option v-for="(item,index) in resourceSubjectGroup" :key="index" :label="item.subjectName"
			                   :value="item.id"></el-option>
		        </el-select>
		        <el-select v-model="params.resourceMajorId" @change="queryByJson">
			        <el-option label="所有资源专业" value="0"></el-option>
			        <el-option v-for="(item,index) in resourceMajorGroup" :key="index" :label="item.majorName"
			                   :value="item.id"></el-option>
		        </el-select>
		        <el-select v-model="params.resourceCourseId" @change="queryByJson">
			        <el-option label="所有资源课程" value="0"></el-option>
			        <el-option v-for="(item,index) in resourceCourseGroup" :key="index" :label="item.courseName"
			                   :value="item.id"></el-option>
		        </el-select>
		        <el-select v-model="params.resourceFormatId" @change="queryByJson">
			        <el-option label="所有资源格式" value="0"></el-option>
			        <el-option v-for="(item,index) in resourceFormatGroup" :key="index" :label="item.formatName"
			                   :value="item.id"></el-option>
		        </el-select>
		        <cms-input label="资源名称" v-model="params.resourceName"></cms-input>
		        <el-button @click="queryByJson">查询</el-button>
	        </div>
        </div>
        <!-- 表格 -->
        <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">
            <el-table-column type="selection" width="65" align="center"></el-table-column>
            <el-table-column prop="resourceInfo.resourceName" label="资源名称" width="180" align="center"></el-table-column>
		        <el-table-column prop="resourceInfo.resourceType.typeName" label="资源类型" align="center"></el-table-column>
		        <el-table-column prop="resourceInfo.resourceSubject.subjectName" label="资源学科" align="center"></el-table-column>
		        <el-table-column prop="resourceInfo.resourceMajor.majorName" label="资源专业" align="center"></el-table-column>
		        <el-table-column prop="resourceInfo.resourceCourse.courseName" label="资源课程" align="center"></el-table-column>
		        <el-table-column prop="resourceInfo.resourceFormat.formatName" label="资源格式" align="center"></el-table-column>
            <el-table-column prop="resourceInfo.fileName" label="附件名称" align="center"></el-table-column>
            <el-table-column prop="resourceInfo.userName" label="上传人" align="center"></el-table-column>
            <el-table-column prop="applyUserName" label="申请人" align="center"></el-table-column>
            <el-table-column prop="applyStatus" label="状态" align="center">
                <div slot-scope="scope">
                    <span v-if="scope.row.applyStatus=='1'" style="color: #2cbb14">已通过</span>
                    <span v-if="scope.row.applyStatus=='0'" style="color: #ff4a31">被驳回</span>
                </div>
            </el-table-column>

            <el-table-column prop="name" label="操作" align="center">
                <div slot-scope="scope">
                    <cms-button type="view"
                                @click.native="routerLink('/resourceVerifyHistory/view','update',scope.row.id)"
                                v-perms="'/resourceVerifyHistory/view'"
                    ></cms-button>
                    <cms-button type="delete" @click.native="deleteBatchByJson($api.resourceVerifyDelete,scope.row.id)"
                    ></cms-button>
                </div>
            </el-table-column>
        </el-table>
        <!-- 表格底部 -->
        <div class="cms-list-footer">
            <div class="cms-left">
                <el-button :disabled="disabled" @click="deleteBatchByJson($api.resourceVerifyDelete,ids)"
                >批量删除
                </el-button>
            </div>
            <!-- cms分页组件 -->
            <cms-pagination :total="total" @change="getPagesByJson"></cms-pagination>
        </div>
    </section>
</template>

<script>
    import listMixins from '@/mixins/list'
    import {signParams} from '@/untils/sign';
    import axios from "axios";
    import qs from 'qs'

    export default {
        mixins: [listMixins],
        data() {
            return {
                params: {//只需要业务参数
                    resourceName: "",
                    history: "1",
                    pageNo: "",
                    pageSize: ""
                }
                , downParam: {
                    appId: '',
                    sessionKey: '',
                    names: '',
                },
                resourceTypeGroup: [],
                resourceSubjectGroup: [],
                resourceMajorGroup: [],
                resourceCourseGroup: [],
                resourceFormatGroup: [],
            };
        },
        created() {
            this.getResourceTypeGroup();
            this.getResourceSubjectGroup();
            this.getResourceMajorGroup();
            this.getResourceCourseGroup();
            this.getResourceFormatGroup();
            this.initTableDataByJson(this.$api.resourceVerifyList, this.params);
        },
        methods: {
            down(val) {
                //下载
                let link = this.$store.state.sys.baseUrl + val;
                var a = document.createElement("a");
                a.href = link;
                a.click();
            },
            getResourceTypeGroup() {
                this.loading = true;
                axios.post(this.$api.resourceTypeGroup).then(res => {
                    this.loading = false;
                    if (res.code == '200') {
                        this.resourceTypeGroup = res.body;
                    }
                }).catch(error => {
                    this.loading = false;
                })
            },
            getResourceSubjectGroup() {
                this.loading = true;
                axios.post(this.$api.resourceSubjectGroup).then(res => {
                    this.loading = false;
                    if (res.code == '200') {
                        this.resourceSubjectGroup = res.body;
                    }
                }).catch(error => {
                    this.loading = false;
                })
            },
            getResourceMajorGroup() {
                this.loading = true;
                axios.post(this.$api.resourceMajorGroup).then(res => {
                    this.loading = false;
                    if (res.code == '200') {
                        this.resourceMajorGroup = res.body;
                    }
                }).catch(error => {
                    this.loading = false;
                })
            },
            getResourceCourseGroup() {
                this.loading = true;
                axios.post(this.$api.resourceCourseGroup).then(res => {
                    this.loading = false;
                    if (res.code == '200') {
                        this.resourceCourseGroup = res.body;
                    }
                }).catch(error => {
                    this.loading = false;
                })
            },
            getResourceFormatGroup() {
                this.loading = true;
                axios.post(this.$api.resourceFormatGroup).then(res => {
                    this.loading = false;
                    if (res.code == '200') {
                        this.resourceFormatGroup = res.body;
                    }
                }).catch(error => {
                    this.loading = false;
                })
            },
        }
    };
</script>

<style>

</style>
